/***************************************************************************
 *  Filename: groundscommunicator.h
 *  Class: GroundSCommunicator
 *  
 *  Copyright 2012  Jacco van der Spek
 *  <jaccovdspek@gmail.com>
 *
 *  Copyright 2012  Mario Henrique Voorsluys
 *  <forcaeluz@gmail.com>
 *  
 ****************************************************************************/

/*
 *
 * This file is part of %ProjectName%.
 *
 *    %ProjectName% is free software: you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation, either version 3 of the License, or
 *    (at your option) any later version.
 *
 *    %ProjectName% is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License
 *    along with %ProjectName%.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef GROUNDSCOMMUNICATOR_H
#define GROUNDSCOMMUNICATOR_H

#include <QObject>
#include <QFile>

#include <gpsdata.h>
#include <communicationhandler.h>

#include "flightdata.h"

#define HEADER_UAVINFO  0
#define HEADER_CARGPS   31
#define HEADER_IMG      227
#define HEADER_STEER    252

class GroundSCommunicator : public QObject
{
    Q_OBJECT
public:
    explicit GroundSCommunicator(QString ttyPort = "/dev/ttyUSB0", QObject *parent = 0);
    
signals:
    void cmdHover();
    void cmdReturn();
    void cmdTrack();
    void cmdFlyTo();

public slots:
    void sendImage(QString filename);
    void sendFlightInfo(FlightData data);
    void sendTargetInfo(GPSData data);
    void sendSteering(quint8 data);
private:
    CommunicationHandler communicator;
    QByteArray dataReceived;
private slots:
    void receiveByte();
};

#endif // GROUNDSCOMMUNICATOR_H
